package com.tinygray;

/**
 * @Author: tinygray
 * @Description: 公众号:Madison龙少，关注我你会越来越优秀。
 * @className: EqualsTest2
 * @create: 2021-04-10 13:48
 */
public class EqualsTest2 {
    public static void main(String[] args) {
        String str1 = "abc";
        String str2 = new String("abc");
        String str3 = "abc";
        String str4 =  "xxx";
        String str5 = "abc" + "xxx";
        String str6 = str3 + str4;

        System.out.println("str1 == str2：" + (str1 == str2));
        System.out.println("str1.equals(str2)：" + (str1.equals(str2)));
        System.out.println("str1 == str5：" + (str1 == str5));
        System.out.println("str1 == str6：" + (str1 == str6));
        System.out.println("str5 == str6：" + (str5 == str6));
        System.out.println("str5.equals(str6)：" + (str5.equals(str6)));
        System.out.println("str1 == str6.intern()：" + (str1 == str6.intern()));
        System.out.println("str1 == str2.intern()：" + (str1 == str2.intern()));
    }
}

